package com.you.atlas.biz.place.service.impl;

import java.util.List;
import java.util.Map;

import com.you.atlas.biz.place.service.NoteQueryService;
import com.you.common.ibatis.data.DataList;
import com.you.place.dal.dao.NoteDAO;
import com.you.place.dal.dao.NoteItemDAO;
import com.you.place.dal.dao.NotePhotoDAO;
import com.you.place.dal.dao.dataobject.NoteDO;
import com.you.place.dal.dao.dataobject.NoteItemDO;

public class NoteQueryServiceImpl implements NoteQueryService {

    private NoteDAO      noteDAO;
    private NoteItemDAO  noteItemDAO;
    private NotePhotoDAO notePhotoDAO;


    public void setNoteItemDAO(NoteItemDAO noteItemDAO) {
        this.noteItemDAO = noteItemDAO;
    }

    public void setNotePhotoDAO(NotePhotoDAO notePhotoDAO) {
        this.notePhotoDAO = notePhotoDAO;
    }


    public void setNoteDAO(NoteDAO noteDAO) {
        this.noteDAO = noteDAO;
    }


    @Override
    public NoteDO find(Long noteId) {
        return noteDAO.find(noteId);
    }

    @Override
    public DataList queryNoteByPlaceId(int pageNo, Long placeId) {
        return noteDAO.queryByPlaceId(pageNo, 10, placeId);
    }

    @Override
    public DataList queryNoteBymemberId(int pageNo, Long memberId) {
        return noteDAO.queryByMemberId(pageNo, 10, memberId);
    }

    @Override
    public List<NoteItemDO> queryNoteItemByNoteId(Long noteId) {
        List<NoteItemDO> noteItemList = noteItemDAO.queryByNoteId(noteId);
        for (NoteItemDO noteItem : noteItemList) {
            Map<String, String> notePhotoMap = notePhotoDAO.queryMapByNoteItemId(noteItem.getId());
            noteItem.setPhoto(notePhotoMap);
        }
        return  noteItemList ;
    }

    @Override
    public List<NoteDO> find(Long[] id) {
        return noteDAO.find(id);
    }

}
